/* 
*  Copyright (C) 2009-2010 WCG Project
*
*  This program is free software; you can redistribute it and/or modify it
*  under the terms of the GNU General Public License as published by the
*  Free Software Foundation; either version 2 of the License, or (at
*  your option) any later version.
*
*  This program is distributed in the hope that it will be useful, but
*  WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
*  General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software Foundation,
*  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*  In addition, as a special exception, the author gives permission to
*  link the code of this program with the Half-Life Game Engine ("HL
*  Engine") and Modified Game Libraries ("MODs") developed by Valve,
*  L.L.C ("Valve"). You must obey the GNU General Public License in all
*  respects for all of the code used other than the HL Engine and MODs
*  from Valve. If you modify this file, you may extend this exception
*  to your version of the file, but you are not obligated to do so. If
*  you do not wish to do so, delete this exception statement from your
*  version.
*/



/*
*	Common DB Header File
.*/

// Type of SQlite database synchronization
#define SQLITE_SYNC_OFF				0
#define SQLITE_SYNC_NORMAL			1
#define SQLITE_SYNC_FULL			2

// Based on what we're saving by (FT_saveby)
#define DB_SAVEBY_STEAMID			0
#define DB_SAVEBY_IP				1
#define DB_SAVEBY_NAME				2

// Used with g_DBType
#define DB_SQLITE			0
#define DB_MYSQLX			1

// Lets us know that the DB is ready
new bool:bDBAvailable = false;

// Has the user's XP been retrieved since he joined?
new bool:bDBXPRetrieved[33];

// SQLX
new Handle:g_DBTuple;
new Handle:g_DBConn;

// SQLite
//new Sql:g_DB;
new g_DBType = -1;

// Player's Unique ID
new g_iDBPlayerUniqueID[33];
new g_iDBPlayerSavedBy[33];

// Lets us store what level the skill was the last time we saved (so we don't save more than necessary)
new g_iDBPlayerSkillStore[33][MAX_SKILLS];
new g_iDBPlayerXPInfoStore[33][MAX_CLASSES];
new g_iDBPlayerAttributeStore[33][MAX_ATTRIBUTES];

// Function Declarations
forward DB_DetermineType();
forward DB_Init();
forward DB_Close();
forward DB_SaveXP( id, bThreaded );
forward DB_GetKey( id, szKey[], len );
forward DB_GetKeyName( szKeyName[], len );
forward DB_GetAllXP( id );
forward DB_SetDataForRace( id );
forward DB_FormatString( text[], len );
forward DB_UpdateTimestamp( id );
forward DB_Prune();
forward DB_FetchUniqueID( id );
forward DB_GetUniqueID( id );
forward DB_SaveAll( bThreaded );
forward bool:DB_Connection_Available();